<template>
  <view>
    <view class="box" @click="showT">保存</view>
    <view class="box" @click="showT2">获取</view>
    <view class="box" @click="showT2"></view>
  </view>
</template>

<script setup lang="js">
const showT = () => {
  //存字符串
  uni.setStorageSync('a','年后')
  //存数组
  uni.setStorageSync('b',[1,2,3])
}

const showT2 = () => {
  //获取
  uni.getStorageSync('a')
  //获取所有key
  uni.getStorageInfoSync()
  uni.showToast({
    title: uni.getStorageSync('a'),
  });
}

uni.removeStorageSync('a')
uni.clearStorageSync()
</script>


<style scoped lang="scss">
.box{
  height: 40px;
  width: 100%;
  background-color: red;
  margin-top: 10px;
  text-align: left;
  line-height: 40px;
}
</style>
